package DBLayer;

import static org.junit.Assert.*;

import java.sql.Connection;
import java.util.ArrayList;

import org.junit.Test;

import ModelLayer.SalesOrder;

public class DBSalesOrderTest extends DBSalesOrder {

	@Test
	public void testDBSalesOrder() {
		Connection con = DbConnection1.getInstance().getDBcon();
		if(con != null){
			System.out.println("Connection success");
		}
		else
		fail("Not yet implemented");
	}

	@Test
	public void testGetAllSalesOrders() {
		ArrayList<SalesOrder> salesArrayList;
		DBSalesOrder salesObj = new DBSalesOrder();
		salesArrayList = salesObj.getAllSalesOrders(false);
		
		if(salesArrayList.size() == 10){
			System.out.println("succes");
		}
		else
		fail("Not yet implemented properly");
	}

	@Test
	public void testFindSalesOrder() {
		DBSalesOrder salesObj = new DBSalesOrder();
		SalesOrder salesObj1 = salesObj.findSalesOrder("112327", false);
		if(salesObj1 != null){
			System.out.println("SaleId has been found");
		}
		else
		fail("SaleId not found");		
	}

	@Test
	public void testInsertSalesOrder() throws Exception {
		DBSalesOrder salesObj = new DBSalesOrder();
	    SalesOrder salesOrder = new SalesOrder(0,"665566",null,"1978/09/12",5000,"in stock","1978/09/15");
		int salesObj1 = salesObj.insertSalesOrder(salesOrder);
		
		if(salesObj1 != 0){
			System.out.println("Insert success");
		}
		else
		fail("Not yet implemented");
	}

	@Test
	public void testUpdateSalesOrder() {
		fail("Not yet implemented");
	}

	@Test
	public void testDeleteSalesOrder() {
		fail("Not yet implemented");
	}

}
